import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
// import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n('asset.assetCategory.fields');

export const assetCategoryFields = {
  categoryName: t('categoryName'),
  code: t('code'),
  inventoryAlertQuantity: t('inventoryAlertQuantity'),
  description: t('description'),
  imgurlString: t('imgurlString'),
  pid: t('pid'),
};
//列表数据
export const columns: BasicColumn[] = [
  {
    title: assetCategoryFields.categoryName,
    align: 'left',
    dataIndex: 'categoryName',
  },
  {
    title: assetCategoryFields.code,
    align: 'center',
    dataIndex: 'code',
  },
  {
    title: assetCategoryFields.inventoryAlertQuantity,
    align: 'center',
    dataIndex: 'inventoryAlertQuantity',
  },
  // {
  //   title: '有效天数',
  //   align: 'center',
  //   dataIndex: 'effectiveDays',
  // },
  {
    title: assetCategoryFields.description,
    align: 'center',
    dataIndex: 'description',
  },
  {
    title: assetCategoryFields.imgurlString,
    dataIndex: 'imgurlString',
    customRender: ({ text }) => {
      if (text) {
        return render.renderImage({ text, size: 50 });
      }
      return '';
    },
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: assetCategoryFields.categoryName,
    field: 'categoryName',
    component: 'JInput',
    colProps: { span: 6 },

    componentProps: { type: 'like' },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: assetCategoryFields.pid,
    field: 'pid',
    component: 'JTreeSelect',
    componentProps: {
      dict: 'asset_category,category_name,id',
      pidField: 'pid',
      pidValue: '0',
      hasChildField: 'has_child',
    },
  },
  {
    label: assetCategoryFields.categoryName,
    field: 'categoryName',
    component: 'Input',
    dynamicRules: () => {
      return [{ required: true }];
    },
  },
  {
    label: assetCategoryFields.inventoryAlertQuantity,
    field: 'inventoryAlertQuantity',
    component: 'InputNumber',
  },
  // {
  //   label: '有效天数',
  //   field: 'effectiveDays',
  //   component: 'InputNumber',
  // },
  {
    label: assetCategoryFields.description,
    field: 'description',
    component: 'Input',
  },
  {
    label: assetCategoryFields.imgurlString,
    field: 'imgurlString',
    component: 'JImageUpload',
    componentProps: {},
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
